package com.haiberg.osgi.bundle.helloservice.activator;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;

import com.haiberg.osgi.bundle.helloservice.HelloService;
import com.haiberg.osgi.bundle.helloservice.impl.HelloServiceFactory;

public class Activator implements BundleActivator{

	private ServiceRegistration<HelloService> helloServiceRegistration = null;
	
        @Override
	public void start(BundleContext context) throws Exception {
		System.out.println("bundle.HelloService start");
		//HelloService helloService = new HelloServiceImpl();
                HelloServiceFactory factory = new HelloServiceFactory();
		//helloServiceRegistration = (ServiceRegistration<HelloService>) context.registerService(HelloService.class.getName(), helloService, null);
                helloServiceRegistration = (ServiceRegistration<HelloService>) context.registerService(HelloService.class.getName(), factory, null);
	}

        @Override
	public void stop(BundleContext context) throws Exception {
		System.out.println("bundle.HelloService stop");
		helloServiceRegistration.unregister();
	}

}
